home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: wkdugan@ix.netcom.com (Bill Dugan)
- Newsgroups: comp.lang.c++
- Subject: Re: fast sorted-list implementation for event-based sim?
- Date: Wed, 28 Feb 1996 07:26:40 GMT
- Organization: Netcom
- Message-ID: <4h106b$sqa@cloner4.netcom.com>
- References: <Pine.SGI.3.91.960227110848.17017C-100000@golgi>
- NNTP-Posting-Host: lax-ca9-17.ix.netcom.com
- X-NETCOM-Date: Tue Feb 27 11:28:11 PM PST 1996
- X-Newsreader: Forte Free Agent 1.0.82
-
- Take a look at the priority queue in the Standard Template Library. I
- think it's pretty close to what you're asking for.
-
- Joseph Strout <jstrout@ucsd.edu> wrote:
-
- >I'm considering writing an event-based simulation package. The needs are
- >simple: events go into a collection with an event-time; they may be put
- >in in any order (though in general, they will be entered in rough order).
- >They need to be taken out in order. Both operations need to be very fast.
-
- >I've just examined one implementation of such a thing, that builds a big
- >(fixed-size) array of events. To insert an event, it crawls through the
- >array to the first unused slot and sticks it there. To find the next
- >event, it goes through all events sequentially, and finds the one with
- >the earliest event time.
-
- >Surely this could be done better? With a dynamically-allocated linked
- >list, for example, we could insert freely at the end of the list, and do
- >the Find as above. Or will all that new'ing and delete'ing slow me down?
-
- >Perhaps it would be better to maintain the list in sorted order in the
- >first place (i.e., as each event is inserted). This could be done with a
- >b-tree structure, I suppose. (Are there any publicly available
- >implementations of such a data structure?)
-
- >Any advice would be greatly appreciated. This will be used for
- >educational/research freeware, not for commercial purposes.
-
- >,------------------------------------------------------------------.
- >| Joseph J. Strout Department of Neuroscience, UCSD |
- >| jstrout@ucsd.edu http://www-acs.ucsd.edu/~jstrout/ |
- >`------------------------------------------------------------------'
-
-
-
-